package com.zy.kotlinbaselibrary.base.fragment

import android.os.Bundle
import android.widget.Toast
import com.zy.kotlinbaselibrary.base.mvp.BaseView
import com.zy.kotlinbaselibrary.base.mvp.IPresenter

abstract class BasePresenterFragment<V: BaseView, P: IPresenter<V>>: BaseFragment(), BaseView {

    protected val mPresenter by lazy { createPresenter() }

    protected abstract fun createPresenter(): P

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        mPresenter.attachView(this as V)
        super.onActivityCreated(savedInstanceState)
    }


    override fun onDestroy() {

        mPresenter.detachView()
        super.onDestroy()

    }

    override fun onRequestStart() {

    }

    override fun onRequestError(msg: String) {
        //        Toast.makeText(this, "网络异常", Toast.LENGTH_SHORT).show();
        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show()
    }

    override fun onRequestEnd() {

    }

    override fun onInternetError() {

    }


}